package cn.ycc1.boot3aop.proxy;

import org.springframework.cglib.proxy.Proxy;

/**
 * @author ycc
 * @date 2024/11/6
 */
public class DynamicProxy {

    public static Object getProxyInstance(Object target) {
        return Proxy.newProxyInstance(
                target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),
                (proxy, method, args) -> {
                    System.out.println("Dynamic proxy before");
                    Object result = method.invoke(target, args);
                    return result;
                });
    }
}
